cmake_minimum_required(VERSION 3.5)

project(org.ukui.timer)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 添加源文件
set(SOURCES
    plugin/ukui-timer-plugin.cpp
    plugin/timer.cpp
)

# 添加头文件
set(HEADERS
    plugin/ukui-timer-plugin.h
    plugin/timer.h
)

# 添加资源文件
set(RESOURCES
    plugin/res
)

# 添加翻译文件
set(TRANSLATIONS
    translations/ukui-timer_zh_CN.ts
)

# 添加 QML 文件
set(QML_FILES
    ui/main.qml
)

# 添加库
find_package(Qt5 COMPONENTS Quick REQUIRED)

# 添加可执行文件
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS} ${RESOURCES} ${TRANSLATIONS} ${QML_FILES})

# 链接 Qt 库
target_link_libraries(${PROJECT_NAME} Qt5::Quick)

# 安装目标
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/qt/plugins/org.ukui.timer)

# 安装 QML 文件
install(FILES ${QML_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/ui)

# 安装翻译文件
install(FILES ${TRANSLATIONS} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/translations)

# 安装资源文件
install(DIRECTORY ${RESOURCES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/plugin/res)